﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jQueryDemo.DataAccess.DataSet.ClientTableAdapters;
using System.Data;

namespace jQueryDemo.BusinessObject.Entity
{
    public class Client : BusinessObjectBase
    {
        #region Properties
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Dob { get; set; }
        public string Gender { get; set; }
        #endregion

        #region Fields
        private ClientTableAdapter TableAdapter { get { return new ClientTableAdapter(); } }
        #endregion

        #region Public methods
        public override void Load()
        {
            throw new NotImplementedException();
        }

        public override void Insert()
        {
            throw new NotImplementedException();
        }

        public override void Update()
        {
            throw new NotImplementedException();
        }

        public override void Delete()
        {
            throw new NotImplementedException();
        }

        public List<Client> SearchClientByName(string name)
        {
            List<Client> clientList = new List<Client>();
            DataTable dtClient = TableAdapter.SearchClientByName(name);
            foreach (DataRow row in dtClient.Rows)
            {
                Client client = new Client();
                client.LoadRow(row);
                clientList.Add(client);
            }
            return clientList;
        }

        public Client CheckClientAvailability(string fname, string lname)
        {
            Client client = null;
            DataTable dtClient = TableAdapter.CheckClientNameAvailability(fname, lname);
            if (dtClient.Rows.Count > 0)
            {
                client = new Client();
                client.LoadRow(dtClient.Rows[0]);
            }

            return client;
        }
        #endregion
    }
}
